<template>
  <!-- 移入移出的时候添加控制类名的添加和移除 -->
  <li
    :class="isClass ? 'active' : ''"
    @mouseenter="isClass = true"
    @mouseleave="isClass = false"
  >
    <label>
      <input type="checkbox" :checked="done" @click="Check(id)" />
      <span>{{ thing }}</span>
    </label>
    <!-- 这里直接可以拿到id -->
    <button class="btn btn-danger" @click="del(id)">删除</button>
  </li>
</template>

<script>
export default {
  name: "Item",
  // 因为是v-bind传的值 所以需要展开来接
  props: ["id", "thing", "done", "del", "Check"],
  data() {
    return {
      isClass: false,
    };
  },
};
</script>

<style scoped>
/*item*/
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  display: none;
  margin-top: 3px;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}
.active {
  background: #ccd;
}
.active > button {
  display: block;
}
</style>